/*
**  TextView.m, implementation of scrolling text stuff for TextLab.
**  Copyright 1989 NeXT, Inc.  All Rights Reserved.
**  Author: Bruce Blumberg, NeXT Developer Support Group
*/


#import <appkit/appkit.h>
#import "TextView.h"

@implementation TextView:ScrollView

+newFrame:(const NXRect *)tFrame
{	NXRect rect={0.0,0.0,0.0,0.0};
	
	/* create view */
	self = [super newFrame:tFrame];
	
	/* specify scrollbars */
        [[self setVertScrollerRequired:YES] setHorizScrollerRequired:NO];

        [self getContentSize:&(rect.size)];
	theText = [self newText:&rect];
	[self setDocView:theText];
	
	// The following two lines allow the resizing of the scrollview
	// to be passed down to the docView (in this case, the text view 
	// itself).

	[contentView setAutoresizeSubviews:YES];
 	[contentView setAutosizing:NX_HEIGHTSIZABLE | NX_WIDTHSIZABLE];

	 // Create enclosing window, display it and bring it upfront
	[self makeEnclosingWindow:tFrame];
	[window setTitle:"Untitled"];
	[window display];
	[window makeKeyAndOrderFront:self];
	[theText setSel:0:0];		
	return(self);
}

-makeEnclosingWindow:(const NXRect *)r
{
    id tWin;
    
    tWin = [Window newContent:r style:NX_TITLEDSTYLE 
		backing:NX_BUFFERED buttonMask:NX_ALLBUTTONS defer:NO];
    [tWin setContentView:self];
    [tWin setBackgroundGray:NX_WHITE];
    [tWin setFreeWhenClosed:YES];
    return self;
}
    
-newText:(const NXRect *)tF
{
	id text = [Text newFrame:tF text:NULL alignment:NX_LEFTALIGNED];
	[text setOpaque:YES];
	[[[[[text notifyAncestorWhenFrameChanged:YES]
		setVertResizable:YES]
		setHorizResizable:NO]
		setMonoFont:NO]
		setDelegate:self];
	
	{ NXSize aSize = {1.0E38,1.0E38};
	  [text setMinSize:&tF->size];
	  [text setMaxSize:&aSize];
        }
	[text setCharFilter:NXEditorFilter];
	return text;
}

@end
	
 

